package com.example.demo.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class MyAspectDemo {
    @Around("@annotation(com.example.demo.aspect.MyAspect)")
    public Object timeRecord(ProceedingJoinPoint pjp)  {
        log.info("目标方法执行前...");

        Object proceed= null;
        try {
            proceed = pjp.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        log.info("目标方法执行后.....");

        return proceed;
    }
}
